<template>
    <div>
        <Header v-if="isShow1"/>
        <PhyTable v-if="isShow1" :arr='arr' @searchBtn='searchBtn' @seeFormBtn='seeFormBtn'/>
        <PhyPage  v-if="isShow1" :page="page" :pageSize="pageSize" :total="total" @changeCurrent='changeCurrent' @changePageSize='changePageSize' style="margin-top:10px;"/>
        <SeeForm :obj='obj' v-if="isShow" @editInfo='editInfo' @off='off' @watchbtnShow='watchbtn'/>
        <Watch v-if="watchSHow" :obj='obj' :bodyObj='bodyObj' :blood='blood' @backHome='backHome'/>
    </div>
</template>

<script>
import Header from './components/PhyHeader'
import PhyTable from './components/PhyTable'
import PhyPage from './components/PhyPage'
import SeeForm from './components/SeeForm'
import Watch from './components/watchTable'
import { getPhydata,PhyUpdata,phyBody,PhyBlood} from "@/api/phy";
export default {
  data() {
    return {
      arr:[],
      page:1,
      pageSize:10,
      total:0,
      state:'',
      time:'',
      isShow1:true,//控制查看页显示隐藏
      isShow:false,//控制查看页显示隐藏
      watchSHow:false,
      obj:{},
      bodyObj:[],
      blood:[]
    }
  },
  components:{
    Header,
    PhyTable,
    PhyPage,
    SeeForm,
    Watch
  },
  methods:{
    getData(){
      let info={
        page:this.page,
        pageSize:this.pageSize,
        state:this.state,
        time:this.time
      }
      // 首页数据
      getPhydata(info).then(res=>{
        console.log(res);
        if(res.code==200){
          this.arr = res.data
          // this.arr.forEach(item=>{
          //   console.log(Date.parse(item.makeTime),111111111111111111);
          // })
          this.total = res.total
        }
      })
    },
    // 改变当前页
    changeCurrent(val){
      this.page=val
      // console.log(val);
       this.getData()
    },
    // 改变一页多少条数据
    changePageSize(val){
       this.pageSize=val
       this.page=1
       this.getData()
    },
    // 搜索
    searchBtn(val,time){
      this.time=time
      this.state=val
      this.getData()
    },
    // 查看显示页
    seeFormBtn(val){
      this.obj=val.row
      this.isShow =!this.isShow
      this.isShow1 =!this.isShow1

    },
    // 修改数据
    editInfo(val){
      console.log(val);
      PhyUpdata(val).then(res=>{
        if(res.code==200){
          this.getData()
          this.isShow=!this.isShow
          this.isShow1 =!this.isShow1
        }
      })
    },
    //取消
    off(){
      this.isShow1=!this.isShow1
      this.isShow=false
    },
    watchbtn(){
      this.watchSHow=!this.watchSHow
      this.isShow =!this.isShow
       phyBody().then(res=>{
         this.bodyObj=res.data
       })
       PhyBlood().then(res=>{
         console.log(res);
         this.blood=res.data
       })

    },
    backHome(){
      this.isShow=true
      this.watchSHow=false
    }

  },
  mounted(){
    this.getData()

  }



}
</script>

<style>

</style>